package com.project.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.entity.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author zhangyang
 * @since 2021-10-06
 */
@Repository
public interface TOrderMapper extends BaseMapper<Order> {
    /**
     * 通过编号和具体日期查询指定的订单集合和订单详情
     *
     * @param businessCode 编号
     * @param time         具体日期
     * @return 订单集合
     */
    List<Order> findByBusinessCodeAndTime(@Param("code") String businessCode,
                                          @Param("time") LocalDate time);

    List<Order> findByCustomCodeAndTime(@Param("code") String customCode,
                                        @Param("time") LocalDate time);

    List<Order> findByRiderCodeAndTime(@Param("code") String riderCode,
                                       @Param("time") LocalDate time);

    /**
     * 根据商家编号查询总订单数和总收入
     *
     * @param businessCode 商家编号
     * @return 商家对象
     */
    Business findBusiness(String businessCode);

    Customer findCustom(String customCode);

    Rider findRider(String riderCode);

    /**
     * 查询指定订单统计
     * 需要从数据库中统计出今日订单数量、今日总金额、本月订单数量、本月总金额封装成为RiderCount
     *
     * @param businessCode 编号
     *                     //     * @param time 具体时间
     * @return 订单统计
     */
    OrderCount findCountByBusiness(@Param("code") String businessCode,
                                   @Param("time") LocalDate time);

    OrderCount findByBusiness(@Param("code") String businessCode,
                              @Param("month") Integer month);

    OrderCount findCountByCustom(@Param("code") String customCode,
                                 @Param("time") LocalDate time);

    OrderCount findByCustom(@Param("code") String customCode,
                            @Param("month") Integer month);

    //
    OrderCount findCountByRider(@Param("code") String riderCode,
                                @Param("time") LocalDate time);

    OrderCount findByRider(@Param("code") String riderCode,
                           @Param("month") Integer month);


}
